package io

import (
	"fmt"
	"sync"
)

func mainF(){
	done:=make(chan bool)
	wg:=sync.WaitGroup{}
	for i:=0;i<5;i++{
		wg.Add(1)
		go f(&wg,done)
	}
	close(done)
	wg.Wait()
	fmt.Println("main quit")
}

func f(wg *sync.WaitGroup,done chan bool){
	defer fmt.Println("goroutine quit")
	defer wg.Done()
	for {
		select {
		case _,beforeClosed:=<-done:
			if !beforeClosed{
				return
			}
		default:
		}
	}

}